/* 
* ---------------------------------------------------------------------
* Copyright (c) 2014, 2015 All Right Reserved
* This software is developed for study and improve coding skill ... 
* 
* Project:  Excellent Coding < EC >
* 
* ecBaseType.h
* This file for redefing all the C++ basic types.
*
* Eamil:   epengao@126.com
* Author:  Peter Gao
* Version: Intial first version.
* --------------------------------------------------------------------
*/

#ifndef EC_BASE_TYPE_H
#define EC_BASE_TYPE_H

#include "ecPlatformDepType.h"

#ifdef __cplusplus
extern "C" {
#endif

namespace ec {

/* signed type */
typedef _CHAR               EC_CHAR;
typedef _SHORT              EC_SHORT;
typedef _LONG               EC_LONG;
typedef _S32                EC_S32;
typedef _S64                EC_S64;
typedef _FLOAT              EC_FLOAT;
typedef _DOUBLE             EC_DOUBLE;
typedef _LONG_DOUBLE        EC_LDOUBLE;
typedef _WCHAR              EC_WCHAR;

/* unsigned domain */ 
typedef _U8                 EC_U8;
typedef _U16                EC_U16;
typedef _U32                EC_U32;
typedef _U64                EC_U64;

/* bool */
typedef _BOOL               EC_BOOL;

#ifdef __cplusplus
#define EC_FALSE           false
#define EC_TRUE            true
#else
#define EC_FALSE           _FALSE
#define EC_TRUE            (!EC_FALSE)
#endif

/* void */
#define EC_VOID            void

/* pointer */
typedef _POINTER          EC_PTR;
typedef _POINTER          EC_POINTER;
typedef EC_POINTER        EC_HANDLE;
typedef EC_POINTER        EC_FUNENTRY;
typedef EC_CHAR*          EC_PCHAR;
typedef EC_SHORT*         EC_PSHORT;
typedef EC_S32*           EC_PS32;
typedef EC_LONG*          EC_PLONG;
typedef EC_S64*           EC_PS64;
typedef EC_FLOAT*         EC_PFLOAT;
typedef EC_DOUBLE*        EC_PDOUBLE;
typedef EC_LDOUBLE*       EC_P_LDOUBLE;
typedef EC_U8*            EC_PU8;
typedef EC_U16*           EC_PU16;
typedef EC_U32*           EC_PU32;
typedef EC_U64*           EC_PU64;
typedef EC_BOOL*          EC_PBOOL;
typedef EC_WCHAR*         EC_PWCHAR;
typedef EC_CHAR*          EC_BUFFER;
#define EC_NULL           _NULL

/* max define */
#define EC_MAX_U8         _MAX_U8
#define EC_MAX_U16        _MAX_U16
#define EC_MAX_U32        _MAX_U32
#define EC_MAX_U64        _MAX_U64

/* time struct */
typedef struct
{
    EC_U32 m_nHour;
    EC_U32 m_nMinute;
    EC_U32 m_nSecond;
    EC_U32 m_nMilliseconds;
} EC_Time;

/* date and time struct*/
typedef struct
{
    EC_U32  m_nYear;
    EC_U32  m_nMonth;
    EC_U32  m_nDay;
    EC_Time m_nTime;
    EC_U32  m_nDayOfWeek;
} EC_Date;


/* Following is the alwyas used return code define */
#define    EC_Err_None                   0x00000000
#define    EC_Err_DataNotExist           0x00000001
#define    EC_Err_NotImplement           0x00000002
#define    EC_Err_BadParam               0x00000003
#define    EC_Err_DataAlreadyExist       0x00000004
#define    EC_Err_FileOpenFaild          0x00000005
#define    EC_Err_OperatorFaild          0x00000006

#define    EC_Err_Memory_Base            0x0000F000
#define    EC_Err_Memory_Overflow        (EC_Err_Memory_Base|0x01)
#define    EC_Err_Memory_NotAvailable    (EC_Err_Memory_Base|0x02)

} /* namespace ec */
#ifdef __cplusplus
}
#endif

#endif /* EC_BASE_TYPE_H */
